<template>
  <div>
    <div style="width: 94%;margin-left: 3%">
      <el-row>
        <el-button type="small" icon="el-icon-caret-left" @click="goback">返回</el-button>
      </el-row>
    </div>
    <el-carousel :interval="1000" type="card" height="300px" :loop="false">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <el-image :src="item.imageUrl" fit="fill" style="height: 100%"></el-image>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import {format} from "../../api";

export default {
  props: {
    // bannerList: Array
  },
  name: 'BannerShow',
  data() {
    return {
      bannerList: []
    }
  },
  created() {
    this.getList();
  },
  methods: {
    goback() {
      this.$router.push({name: '/Banner/main'})
    },

    showImage(imageUrl) {
      return 'url(' + imageUrl + ')';
    },
    /* 将所有幻灯片查询出来 */
    getList() {
      this.$axios.get('/sys/banner')
        .then((res) => {
          console.log(res);
          let tableData = res.data.data;
          tableData.forEach((e) => {
            e.updateTime = format(e.updateTime)
          })
          this.bannerList = tableData;

        })
        .catch((err) => {

        })
    }

  }
}
</script>

<style scoped>
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
</style>
